package com.lengyu.vxminiprogram.security.exception;

import com.lengyu.vxminiprogram.common.HttpResultDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionControllerAdvice {
    private Logger logger = LoggerFactory.getLogger(ExceptionControllerAdvice.class);
    @ExceptionHandler(value = Exception.class)
    public HttpResultDto<String> SimpleExceptionHandler(Exception e){
        logger.error("ex",e);
        return HttpResultDto.failed(e.getMessage() == null? e.getClass().getName() : e.getMessage());
    }

    @ExceptionHandler(value = TokenException.class)
    public HttpResultDto<String> tokenParseFail(TokenException e){
        logger.error("ex",e);
        return HttpResultDto.failed(e.getMessage());
    }

}
